const express = require('express');
const router = express.Router();

router.get('/', (req, res) => {
    res.json({
        message: 'ok',
        payload: {
            content: [
                {
                    id: '1',
                    type: 1,
                    warrantyMileage: 1000,
                    warrantyDuration: 20,
                    partWarrantyPolicyId: 'string1',
                    code: 'string1',
                    name: 'string1',
                    dealerId: 'dealerId',
                    dealerCode: 'dealerCode',
                    dealerName: 'dealerName',
                    brandCode: 'brandCode',
                    startDate: '2019-07-05T07:29:41.856Z',
                    status: 1,
                    creatorName: 'string',
                    createTime: '2019-07-05T07:29:41.856Z',
                    options: [
                        'update',
                        'abandon',
                        'enable'
                    ]
                },
                {
                    id: '2',
                    type: 1,
                    warrantyMileage: 1000,
                    warrantyDuration: 20,
                    partWarrantyPolicyId: 'string2',
                    code: 'string2',
                    name: 'string2',
                    dealerId: 'dealerId',
                    dealerCode: 'dealerCode',
                    dealerName: 'dealerName',
                    brandCode: 'brandCode',
                    startDate: '2019-07-05T07:29:41.856Z',
                    status: 1,
                    creatorName: 'string',
                    createTime: '2019-07-05T07:29:41.856Z',
                    options: [
                        'update',
                        'abandon',
                        'enable'
                    ]
                }
            ],
            totalElements: 50
        }
    });
});

router.get('/:id', (req, res) => {
    const type = parseInt((Math.random() * 2) + 1, 10);
    res.json({
        message: '成功',
        payload: {
            id: 'id209',
            type,
            warrantyDuration: 1,
            warrantyMileage: 1,
            remark: 'remark',
            vehicleCategoryItems: type === 1 ? [
                {
                    id: 'id210',
                    productCategoryId: 'productCategoryId211',
                    productCategoryCode: 'productCategoryCode212',
                    productCategoryName: 'productCategoryName213',
                    vehicleProperty: 1,
                    partWarrantyCategories: [
                        {
                            id: 'id214',
                            code: 'code215',
                            name: 'name216',
                            remark: 'remark'
                        }
                    ]
                },
                {
                    id: 'id217',
                    productCategoryId: 'productCategoryId218',
                    productCategoryCode: 'productCategoryCode219',
                    productCategoryName: 'productCategoryName220',
                    vehicleProperty: 1,
                    partWarrantyCategories: [
                        {
                            id: 'id214',
                            code: 'code215',
                            name: 'name216',
                            remark: 'remark'
                        }
                    ]
                }
            ] : [],
            vehicleItems: type === 2 ? [
                {
                    vehicleId: 'vehicleId221',
                    vin: 'vin2',
                    parts: [
                        {
                            id: 'id222',
                            code: 'code223',
                            name: 'name224',
                            remark: 'remark',
                        }
                    ]
                },
                {
                    vehicleId: 'vehicleId225',
                    vin: 'vin1',
                    parts: [
                        {
                            id: 'id222',
                            code: 'code223',
                            name: 'name224',
                            remark: 'remark',
                        }
                    ]
                }
            ] : []
        }
    });
});
module.exports = router;
